package com.system.connect.springboot_flowers.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.system.connect.springboot_flowers.entity.PostMetrics;
import com.system.connect.springboot_flowers.mapper.PostMetricsMapper;
import com.system.connect.springboot_flowers.service.IPostMetricsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 帖子信息 服务实现类
 * </p>
 *
 * @author yang
 * @since 2025-02-19
 */
@Service
public class PostMetricsServiceImpl extends ServiceImpl<PostMetricsMapper, PostMetrics> implements IPostMetricsService {

    @Override
    public boolean exists(QueryWrapper<PostMetrics> queryWrapper) {
        return getOne(queryWrapper) != null;
    }
    
    @Override
    public PostMetrics getByPostId(Integer postId) {
        if (postId == null) {
            return null;
        }
        
        LambdaQueryWrapper<PostMetrics> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PostMetrics::getPostId, postId);
        return getOne(queryWrapper);
    }
}
